<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl"/>

    <script>
        $(function () {

            $(".checkContent").click(function () {
                var id = $(this).data("id")
                $.get("/travel/getContent.do", {id: id}, function (data) {
                    $("#contentModal .modal-body").html(data.travelContent.content)
                    $("#contentModal").modal("show")
                })
            })
            <#list existTravels as t>
            $("#editForm select option[value='${t.id}']").remove()
            </#list>
            $("#inputBtn").click(function () {
                $("#editForm").clearForm(true)
                $("#strategyId").val($("#strategySelect option:selected").html())
                $("#editForm input[name=strategyId]").val($("#strategySelect option:selected").val())
                 $("#updateModel").modal("show")
            })
            //去重




            $(".saveBtn").click(function () {
                console.log("??");
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success) {
                        $.messager.confirm("成功","确认后返回")
                        location.reload()
                    }else {
                        $.messager.alert("失败",data.msg)
                    }
                })
            })
            
        })
    </script>
    <style>
        #contentModal img{
            width: 100%;
        }
        #contentModal {
            max-height: 500px;  //最大高度
        overflow-y: auto;   //超过最大高度,自动滚动
        }
    </style>

</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
        <#--设置当前要回显当前菜单,必须在载人菜单前完成设置-->
            <#assign menu="strategyTravel"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">大家都在看</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <div class="form-group">
                    <label>攻略搜索:</label>
                    <select id="strategySelect"  class="form-control" name="strategyId" value="${(qo.strategyId)!}">
                        <option value="-1">--请选择--</option>
                        <#list strategies as s >
                            <option value="${s.id}">${s.title}</option>
                        </#list>
                    </select>
                    <script>
                        $("#searchForm select").val(${(qo.strategyId)!})
                    </script>
                </div>
                <button  class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <button id="inputBtn" type="button" class="btn btn-success">
                    <span class="glyphicon glyphicon-plus"></span> 新增
                </button>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>关联游记</th>
                    <th></th>
                    <th></th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity.title!}</td>
                        <td>
                            <a href="javaScript:;" class="checkContent" data-id="${entity.id}">查看游记文章</a>
                        </td>
                        <td>
                            <a href="/strategyTravel/delete.do?id=${entity.id}" class="deleteBtn">删除</a>
                        </td>
                    </tr>
                </#list>
            </table>
           <#include "../common/page.ftl"/>
        </div>
    </div>
</div>

<!-- 内容显示（Modal） -->
<div class="modal fade" id="contentModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabels">
                    编辑
                </h4>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>
<!-- 添加 -->
<div>
<div class="modal fade" id="updateModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    编辑
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/strategyTravel/save.do" method="post" id="editForm">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">所属攻略：</label>
                        <div class="col-sm-6">
                            <input type="text"  class="form-control" id="strategyId" readonly />
                            <input type="hidden"  class="form-control"  name="strategyId" readonly />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">关联游记：</label>
                        <div class="col-sm-6">
                            <select type="text" class="form-control" name="travelId"
                                    placeholder="请输入游记的名称">
                                <#list travels as entity>
                                   <option value="${entity.id}">${entity.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary saveBtn">
                    <span class="glyphicon glyphicon-saved"></span> 提交更改
                </button>
            </div>
        </div>
    </div>
</div>
</div>
</body>
</html>